

package modules

import (
	"game/game-design/loader"
	sanguodesign "sanguo/sanguo-design/src"
	"sanguo/sanguo-design/src/modules/tables"

	"go.uber.org/zap"
)

func LoadTables(designFiles map[string]*loader.DesignFile) {
	tableMap := make(map[string]loader.IDesignTable)

	tableMap[tables.GlobalTable.FileName()] = tables.GlobalTable
	tableMap[tables.ItemDropTable.FileName()] = tables.ItemDropTable
	tableMap[tables.ItemTable.FileName()] = tables.ItemTable
	tableMap[tables.SkillTable.FileName()] = tables.SkillTable
	tableMap[tables.SkillLevelTable.FileName()] = tables.SkillLevelTable
	tableMap[tables.SkillLogicTable.FileName()] = tables.SkillLogicTable
	tableMap[tables.ModelTable.FileName()] = tables.ModelTable
	tableMap[tables.LanguageAutoTable.FileName()] = tables.LanguageAutoTable
	tableMap[tables.LanguageTipsTable.FileName()] = tables.LanguageTipsTable
	tableMap[tables.LanguageCustomizeTable.FileName()] = tables.LanguageCustomizeTable
	tableMap[tables.LanguageNameTable.FileName()] = tables.LanguageNameTable
	tableMap[tables.BattleAttrTable.FileName()] = tables.BattleAttrTable
	tableMap[tables.BattleTypeTable.FileName()] = tables.BattleTypeTable
	
	for key, table := range tableMap {
		file, ok := designFiles[key]
		if !ok {
			continue
		}
		table.SetParser(&sanguodesign.SanguoDesignParser{})
		table.Load(file)
		table.LoadAutoGenerate()
		table.LoadAfterReady()
		zap.L().Info("配置加载", zap.String("file", table.FileName()), zap.Int("size", table.Size()))
	}
	for _, table := range tableMap {
		table.LoadAfterAllReady()
	}
}

